import jsonpath
info = {
    "error_code": 0,
    "stu_info": [
        {
            "id": 2059,
            "name": "小白",
            "sex": "男",
            "age": 28,
            "addr": "河南省济源市北海大道xx号",
            "grade": "天蝎座",
            "phone": "1837830xxxx",
            "gold": 10896,
            "info": {
                "card": 12345678,
                "bank_name": '中国银行'
            }
        },
        {
            "id": 2067,
            "name": "小黑", 
            "sex": "男",
            "age": 28,
            "addr": "河南省济源市北海大道xx号",
            "grade": "天蝎座",
            "phone": "87654321",
            "gold": 100
        }
    ]
}

"""
未使用jsonpath时，提取dict时的方式
"""
result = info['stu_info'][0]['name']
print(result)
result = info['stu_info'][1]['name']
print(result)
"""
使用jsonpath时，提取dict时的方式
返回的列表对象，
"""
result = jsonpath.jsonpath(info, '$.stu_info[0].name')
print(result)
result = jsonpath.jsonpath(info, '$.stu_info[1].name')
print(result)

result = jsonpath.jsonpath(info,'$..name')
print(result)